//app.js
App({

  onShow:function(e){
    if(this.globalData.isShow){
      this.globalData.isShow=false;
      if (e.path == "pages/brandSelect") {
        if (e.query.otherId) {
          if (e.query.otherId != "undefined") {
            wx.reLaunch({
              url: 'pages/brandSelect?otherId=' + e.query.otherId,
            })
          } else {
            wx.reLaunch({
              url: 'pages/brandSelect',
            })
          }
        } else {
          wx.reLaunch({
            url: 'pages/brandSelect',
          })
        }
      }
      if (e.path == "pages/member/tab1/agent/applyAgent"){
        wx.reLaunch({
          url: 'pages/member/tab1/agent/applyAgent?banrdId=' + e.query.banrdId + '&userId=' + e.query.userId,
        })
      }

      if (e.path == "pages/member/tab1/sugarSpice"){
        if (e.query.id && e.query.id != "" && e.query.id !="undefined"){
          wx.reLaunch({
            url: 'pages/member/tab1/sugarSpice?id=' + e.query.id,
          })
        } else if (e.query.userId && e.query.banrdId){
          wx.reLaunch({
            url: 'pages/member/tab1/sugarSpice?userId=' + e.query.userId + "&banrdId=" + e.query.banrdId,
          })
        }
      }
      if (e.path =="pages/member/tab1/articel/gzyl"){
        wx.reLaunch({
          url: 'pages/member/tab1/articel/gzyl?parma=' + e.query.parma,
        })
      }
      if (e.path == "pages/member/tab3/coupon/gzcoupon") {
        wx.reLaunch({
          url: 'pages/member/tab3/coupon/gzcoupon?pmarms=' + e.query.pmarms,
        })
      }
      if (e.path == "pages/member/tab1/articel/articleDetail") {
        var parmas = { otherId: e.query.userId }
        ux.loginArt(parmas, function (protocol) {
          wx.reLaunch({
            url: 'pages/member/tab1/articel/articleDetail?aId=' + e.query.pmarms.aId,
          })
        })
      }
      if (e.path == "pages/member/tab1/red/redGet") {
        wx.reLaunch({
          url: '/pages/member/tab1/red/redGet?merchant=' + e.query.merchant + '&redId=' + e.query.redId + "&memberId=" + e.query.memberId,
        })
      }
    }

  },
  onLoad: function (e) {

    if (e.path == "pages/brandSelect") {
      if (e.query.otherId) {
        if (e.query.otherId != "undefined") {
          wx.reLaunch({
            url: 'pages/brandSelect?otherId=' + e.query.otherId,
          })
        } else {
          wx.reLaunch({
            url: 'pages/brandSelect',
          })
        }
      } else {
        console.log("aaaaaaaa")
        wx.reLaunch({
          url: 'pages/brandSelect',
        })
      }
    }
    if (e.path == "pages/member/tab1/agent/applyAgent") {
      wx.reLaunch({
        url: 'pages/member/tab1/agent/applyAgent?banrdId=' + e.query.banrdId + '&userId=' + e.query.userId,
      })
    }
    if (e.path == "pages/member/tab1/sugarSpice") {
      if (e.query.id && e.query.id != "" && e.query.id != "undefined") {
        wx.reLaunch({
          url: 'pages/member/tab1/sugarSpice?id=' + e.query.id,
        })
      } else if (e.query.userId && e.query.banrdId) {
        wx.reLaunch({
          url: 'pages/member/tab1/sugarSpice?userId=' + e.query.userId + "&banrdId=" + e.query.banrdId,
        })
      }
    }
    if (e.path == "pages/member/tab1/articel/gzyl") {
      wx.reLaunch({
        url: 'pages/member/tab1/articel/gzyl?parma=' + e.query.parma,
      })
    }
    if (e.path == "pages/member/tab3/coupon/gzcoupon") {
      wx.reLaunch({
        url: 'pages/member/tab3/coupon/gzcoupon?pmarms=' + e.query.pmarms,
      })
    }
    if (e.path == "pages/member/tab1/articel/articleDetail") {
      var parmas = { otherId: e.query.userId }
      ux.loginArt(parmas, function (protocol) {
        wx.reLaunch({
          url: 'pages/member/tab1/articel/articleDetail?aId=' + e.query.pmarms.aId,
        })
      })
    }
    if (e.path == "pages/member/tab1/red/redGet") {
      wx.reLaunch({
        url: '/pages/member/tab1/red/redGet?merchant=' + e.query.merchant + '&redId=' + e.query.redId + "&memberId=" + e.query.memberId,
      })
    }
    
  },
  onLaunch: function (e) {


    if (e.path == "pages/brandSelect") {
      if (e.query.otherId) {
      if (e.query.otherId != "undefined") {
        wx.reLaunch({
          url: 'pages/brandSelect?otherId=' + e.query.otherId,
        })
      } else {
        wx.reLaunch({
          url: 'pages/brandSelect',
        })
      }
      }else{
        wx.reLaunch({
          url: 'pages/brandSelect',
        })
      }
    }
    if (e.path == "pages/member/tab1/agent/applyAgent") {
      wx.reLaunch({
        url: 'pages/member/tab1/agent/applyAgent?banrdId=' + e.query.banrdId + '&userId=' + e.query.userId,
      })
    }

    if (e.path == "pages/member/tab1/sugarSpice") {
      if (e.query.id && e.query.id != "" && e.query.id != "undefined") {
        wx.reLaunch({
          url: 'pages/member/tab1/sugarSpice?id=' + e.query.id,
        })
      } else if (e.query.userId && e.query.banrdId) {
        wx.reLaunch({
          url: 'pages/member/tab1/sugarSpice?userId=' + e.query.userId + "&banrdId=" + e.query.banrdId,
        })
      }
    }
    if (e.path == "pages/member/tab1/articel/gzyl") {
      wx.reLaunch({
        url: 'pages/member/tab1/articel/gzyl?parma=' + e.query.parma,
      })
    }
    if (e.path == "pages/member/tab3/coupon/gzcoupon") {
      wx.reLaunch({
        url: 'pages/member/tab3/coupon/gzcoupon?pmarms=' + e.query.pmarms,
      })
    }
    if (e.path == "pages/member/tab1/articel/articleDetail") {
      var parmas = { otherId: e.query.userId }
      ux.loginArt(parmas, function (protocol) {
        wx.reLaunch({
          url: 'pages/member/tab1/articel/articleDetail?aId=' + e.query.pmarms.aId,
        })
      })
    }
    if (e.path == "pages/member/tab1/red/redGet") {
      wx.reLaunch({
        url: '/pages/member/tab1/red/redGet?merchant=' + e.query.merchant + '&redId=' + e.query.redId + "&memberId=" + e.query.memberId,
      })
    }
  },
  globalData: {
    isShow:true,
    thisBrand:"",
    userInfo: ""
  }
})